﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GenericEntities;
using System.Timers;
using GoogleAdapter;
using System.Collections;

namespace DataSynchronizer
{
    public class SyncService
    {
        SyncManager<GenericEvent> eventManager = new SyncManager<GenericEvent>();
        public string LastUpdateDate;
        public SyncService(string id, string pass)
        {
            //Initialize Event Manager
            eventManager.Name = "..Event Synchronizer";
            eventManager.Source1 = new GoogleEventsSyncDataSource(id,pass);
        }

        public IList SynchronizeEvents()
        {
            //IList list = eventManager.Synchronize(DateTime.Now).ToList();
            IList list = eventManager.Synchronize(DateTime.Now.AddYears(-1)).ToList();
            return list;
        }

        public void addCalendar(GenericEvent genericEvent)
        {
            eventManager.Source1.WriteItem(genericEvent);
        }

        public void updateCalendar(GenericEvent oldGe, GenericEvent newGe)
        {
            eventManager.Source1.UpdateItem(oldGe,newGe);
        }

        public void delCalendar(GenericEvent genericEvent)
        {
            eventManager.Source1.DeleteItem(genericEvent);
        }

        public void delAllCalendar()
        {
            eventManager.Source1.DeleteAllItem();
        }

        public Boolean getLogin()
        {
            return eventManager.Source1.getLogin();
        }
    }
}
